package gao.xiaolei.util;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

public class CronUtil {

    private final static String pattern="ss mm HH dd MM ? yyyy";
        /**
         * 日期转化为cron表达式
         * @param date
         * @return
         */
        public static String getCron(LocalDateTime date){
            return date.format(DateTimeFormatter.ofPattern(pattern));
        }

        /**
         * cron表达式转为日期
         * @param cron
         * @return
         */
        public static LocalDateTime getCronToDate(String cron) {
            return LocalDateTime.parse(cron, DateTimeFormatter.ofPattern(pattern));
        }
}
